#ifndef INI_H_INCLUDED
#define INI_H_INCLUDED

#ifdef __cplusplus
extern "C"
{
#endif

#include "common.h"
#include "task.h"

//------------------------------------------------------------------------------
// defines
//------------------------------------------------------------------------------

#define DATA_DIR                      "..\\data"     // relative to the ini path
#define INI_STATISTICS_SECTION_NAME   "statistics"
#define INI_STATISTICS_KEY_NAME       "LastReportTime"

//------------------------------------------------------------------------------
// enums
//------------------------------------------------------------------------------

enum
{
    MAX_PATH_LENGTH = 512
};

//------------------------------------------------------------------------------
// typedefs
//------------------------------------------------------------------------------

// forwrad declaration to eliminate circular dependencies
typedef struct item item_t;

typedef enum
{
	digest_opt_title,
	digest_opt_title_desc
} digest_opt_t;

typedef enum
{
	format_opt_text,
	format_opt_html
} format_opt_t;

/**
 * @struct customer_t
 *         This struct provides all the data for a customer.
 */
typedef struct customer
{
    char*          name;
    char*          surname;
    char*          email;
	digest_opt_t   digest_opt;
	format_opt_t   format_opt;
    char*          time_zone;
    char**         keywords;             ///< NULL terminated array of keywords
    item_t***      raw_digest;           ///< NULL terminated array of item pointers array
    char*          formatted_digest;     ///< The digest created out of the digets items
} customer_t;

//------------------------------------------------------------------------------
// functions
//------------------------------------------------------------------------------

/**
 * @brief Reads the ini file for all the settings.
 *
 * @param a_ini_path The absolute ini path. If it is NULL, the ini path is set 
 *        by this function. The exe file should be found in the ini file's
 *        parent directory, i.e. in the same directory. The data directory "data"
 *        is expected to be outside the ini file's parent dir, i.e. "..\data".
 *
 * @return true if succeeds and false otherwise.
 */
bool
INI_Init(const char* a_ini_path);

/**
 * @brief Retrieves the agilerss ini file absolute path.
 */
const char*
INI_GetIniPath();

/**
 * @brief Retrieves the agilerss data absolute path.
 */
const char*
INI_GetDataPath();

/**
 * @brief Reads number of sources from file
 *
 * @return Number of urls.
 *
 * @note INI_Init should be called before calling this function.
 */
int
INI_FeedCount();

int
INI_CustomerCount();

const char**
INI_FeedSources();

customer_t*
INI_Customers();

taskschedule_t*
INI_TaskSchedule();

void
INI_Free();

#ifdef __cplusplus
}
#endif

#endif // INI_H_INCLUDED
